import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Req,
  HttpCode,
} from '@nestjs/common';
import { ProjectService } from './project.service';
import { CreateProjectDto } from './dto/create-project.dto';
import { UpdateProjectDto } from './dto/update-project.dto';
import { Auth } from '@/jwt/jwt.decorator';

@Controller('project')
export class ProjectController {
  constructor(private readonly projectService: ProjectService) {}
  //添加项目
  @Post()
  @Auth()
  @HttpCode(200)
  create(@Body() createProjectDto: CreateProjectDto, @Req() req: any) {
    return this.projectService.create(createProjectDto, req);
  }
  //查看所有项目
  @Get()
  @Auth()
  findAll(@Req() req: any) {
    return this.projectService.findAll(req);
  }
  //查看某一个具体项目
  @Get(':id')
  @Auth()
  findOne(@Param('id') id: string, @Req() req: any) {
    return this.projectService.findOne(+id, req);
  }
  //修改项目
  @Patch(':id')
  @Auth()
  update(
    @Param('id') id: string,
    @Body() updateProjectDto: UpdateProjectDto,
    @Req() req: any,
  ) {
    return this.projectService.update(+id, updateProjectDto, req);
  }
  //删除项目
  @Delete(':id')
  @Auth()
  remove(@Param('id') id: string, @Req() req: any) {
    return this.projectService.remove(+id);
  }
}
